package Demo1299.Demo17;

import java.lang.reflect.Method;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("Demo1299.Demo17.Person");
        Object person = aClass.getDeclaredConstructor().newInstance();
        Method setName = aClass.getDeclaredMethod("setName", String.class);
        String p = (String) setName.invoke(person, "张三");
        Method getName = aClass.getDeclaredMethod("getName");
        System.out.println(getName.invoke(person));
    }
}
